<template>
  <div id="basicSider">



      <a-layout-sider width="200" breakpoint="lg" collapsed-width="0"   >
        <a-menu
          v-model:selectedKeys="current"
          :items="menuItems"
          @click="doMenuClick"
          mode="inline"
          :style="{ height: '100%', borderRight: 0 }">



        </a-menu>
      </a-layout-sider>



  </div>
</template>
<script lang="ts" setup>
import { computed, h, ref } from 'vue'
import { PictureOutlined, UserOutlined } from '@ant-design/icons-vue'
import { useRouter } from 'vue-router'
import { useLoginUserStore } from '@/stores/useLoginUserStore.ts'

// 获取登录用户
const loginUserStore = useLoginUserStore()

// 未经处理菜单项
const menuItems = [
  {
    key: '/',
    icon: () => h(PictureOutlined),
    label: '公共图库',
  },
  {
    key: '/my_space',
    icon: () => h(UserOutlined),
    label: '我的空间',
  },

]

const router = useRouter()
// 路由跳转时间
const doMenuClick = ({ key }) => {
  console.log(key)
  router.push({
    path: key,
  })
}



// 当前要高亮的菜单项
const current = ref<string[]>([])
// router.afterEach 跳转之前记录 原来的页面设置给 current 让其高亮
router.afterEach((to, from, next) => {
  console.log(to.path)

  current.value = [to.path]
})
</script>
<style scoped>
#basicSider .ant-layout-sider {
  background: none;
}


</style>
